python3 国内源

您所在的位置:网站首页 python 使用国内源 python3 国内源

python3 国内源

2022-06-01 11:23| 来源: 网络整理| 查看: 265

Python切换pip安装源的方法详解 众所周知pip是Python中非常方便易用的安装包管理器,但是在实际下载安装包的时候总是连接不上或者下载速度特别慢, pypi.python.org就是其中一个。 所以,使用pip给Python安装软件时,经常出现Timeout连接超时错误。修改pip连接的软件库可以解决这个问题。

http://pypi.douban.com是豆瓣提供一个镜像源,软件够新,连接速度也很好。

http://mirrors.aliyun.com/pypi/simple/ 这个阿里云也可以。

方案一:修改配置文件

1)检查pip.conf文件是否存在

>> cd ~ >> mkdir .pip >> ls ~/.pip

2)直接编辑pip.conf

sudo vi ~/.pip/pip.conf [global] index-url = http://mirrors.aliyun.com/pypi/simple/ [install] trusted-host = mirrors.aliyun.com

[global] timeout = 6000 index-url = http://pypi.douban.com/simple/ [install] use-mirrors = true mirrors = http://pypi.douban.com/simple/ trusted-host = pypi.douban.com

方案二:临时换源

命令格式:sudo pip3 install 包名 -i 镜像源url

在这里插入图片描述

比如我在用pip安装tornado的时候,下载速度一直是几k

sudo pip3 install tornado -i https://pypi.douban.com/simple/ sudo pip3 install -i https://pypi.douban.com/simple/ tornado

之后下载速度提到了2MB/s

PyPI常用的几个国内源地址收藏

阿里云 http://mirrors.aliyun.com/pypi/simple/

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

豆瓣(douban) http://pypi.douban.com/simple/

清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/

中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

使用方法很简单,直接 -i 加 url 即可!

原文链接:https://blog.csdn.net/lc11535/article/details/101113856



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3